home *** CD-ROM | disk | FTP | other *** search
/ MacGames Sampler / PHT MacGames Bundle.iso / MacSource Folder / Samples from the CD / Editors / emacs / Emacs-1.14b1-sources / sources / lprd-src / lprd-notify.c next >
Encoding:
C/C++ Source or Header  |  1994-05-25  |  2.3 KB  |  100 lines  |  [TEXT/EMAC]

  1. /*
  2.  * Copyright (C) 1994 Marc Parmet.
  3.  * This file is part of the Macintosh port of GNU Emacs.
  4.  *
  5.  * GNU Emacs is distributed in the hope that it will be useful,
  6.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  7.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  8.  * GNU General Public License for more details.
  9.  */
  10.  
  11. #include <MacHeaders>
  12.  
  13. #define ONE_LINE_DOWN 16
  14.  
  15. static int have_CQD;
  16. static CIconHandle c_icon;
  17. static Handle bw_icon;
  18. static WindowPtr w;
  19. static short last_current_page = -1;
  20. static short last_operation = -1;
  21.  
  22. void
  23. notify_start(void)
  24. {
  25.     short err;
  26.     long response;
  27.     
  28.     err = Gestalt(gestaltQuickdrawVersion,&response);
  29.     have_CQD = !err && (response >= gestalt8BitQD);
  30.     if (have_CQD) {
  31.         if (c_icon == 0L)
  32.             c_icon = GetCIcon(128);
  33.     }
  34.     else {
  35.         if (bw_icon == 0L)
  36.             bw_icon = GetIcon(128);
  37.     }
  38.     w = GetNewWindow(131,0L,(WindowPtr)-1L);
  39.     MoveWindow(w,
  40.         (screenBits.bounds.right - w->portRect.right + w->portRect.left)/2,
  41.         screenBits.bounds.bottom/3 - (w->portRect.bottom - w->portRect.top)/2,0);
  42.     ShowWindow(w);
  43. }
  44.  
  45. void
  46. notify_message(int operation,int current_page,int total_pages,unsigned char *name)
  47. {
  48.     Rect r;
  49.     GrafPtr gp;
  50.     unsigned char s[256],t[256];
  51.     
  52.     if (operation == last_operation && current_page == last_current_page) return;
  53.  
  54.     GetPort(&gp);
  55.     SetPort(w);
  56.     SetRect(&r,0,0,32,32);
  57.     OffsetRect(&r,23 - r.left,13 - r.top);
  58.     if (have_CQD)
  59.         PlotCIcon(&r,c_icon);
  60.     else
  61.         PlotIcon(&r,bw_icon);
  62.     
  63.     switch (operation) {
  64.     case 0:
  65.         // "Formating page " x ".  Press cmd-. to cancel."
  66.         GetIndString(s,128,1);
  67.         NumToString(current_page,t); pstrcat(s,t);
  68.         GetIndString(t,128,2); pstrcat(s,t);
  69.         break;
  70.     case 1:
  71.         if (current_page == 0) {
  72.             // "Printing..."
  73.             GetIndString(s,128,3);
  74.         }
  75.         else {
  76.             // "Printing page " x " of " y ".  Press cmd-. to cancel."
  77.             GetIndString(s,128,4);
  78.             NumToString(current_page,t); pstrcat(s,t);
  79.             GetIndString(t,128,5); pstrcat(s,t);
  80.             NumToString(total_pages,t); pstrcat(s,t);
  81.             GetIndString(t,128,2); pstrcat(s,t);
  82.         }
  83.         break;
  84.     }
  85.     TextFont(0);
  86.     SetRect(&r,78,13,w->portRect.right - 13,w->portRect.bottom - 13);
  87.     TextBox(s+1,s[0],&r,teJustLeft);
  88.     
  89.     last_current_page = current_page;
  90.     last_operation = operation;
  91.     SetPort(gp);
  92. }
  93.  
  94. void
  95. notify_end(void)
  96. {
  97.     DisposeWindow(w);
  98.     FlushEvents(keyDownMask | autoKeyMask,0);
  99. }
  100.